package com.lipiao.traveltreasure.controller.travelTreasure;

import com.lipiao.traveltreasure.bean.travelTreasureBean.OrderBean;
import com.lipiao.traveltreasure.service.travelTreasure.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 控制器-车行宝
 * 订单/travelTreasureApi/order
 * 1.获取所有订单/getOrderList
 * 2.
 */
@Api(tags = "车行宝-订单信息接口")
@Controller
@RequestMapping("/travelTreasureApi/order")
public class OrderController {
    //注入业务对象
    @Resource
    private OrderService orderService;
    //存储预返回页面的结果对象
    private Map<String, Object> result = new HashMap<>();

    //获取所有信息/travelTreasureApi/orderpic/getOrderList
    @ApiOperation("获取订单信息")
    @GetMapping("/getOrderList")
    @ResponseBody
    public Map<String, Object> getOrderList() {
        try {
            List<OrderBean> list = orderService.findAll();
            //存储对象数据
            result.put("OrderList", list);
            result.put("message", "getOrderListSuccess");
        } catch (Exception e) {
            result.put("OrderList", "null");
            result.put("message", "getOrderListError");
            e.printStackTrace();
        } finally {
            return result;
        }

    }

}
